<?php 
	if(isset($_POST['submitted'])) {
		// require a name from user
			$name = trim($_POST['nombre']);

		// need valid email
			$email = trim($_POST['email']);
		// we need at least some content
		if(function_exists('stripslashes')) {
			$comments = stripslashes(trim($_POST['body']));
		} else {
			$comments = trim($_POST['body']);
		}
		
			

		$emailTo = 'contacto@nlogic.cl';
		$subject = 'CONTACTO SITIO '.$name;
		$body = "Nombre: $name \n\nEmail: $email \n\nMensaje: $comments";
		$headers = 'From: ' .' <'.$emailTo.'>';

		mail($emailTo, $subject, $body, $headers);
	    
	    // set our boolean completion value to TRUE
		$emailSent = true;
	
	}
?>
<script type="text/javascript">
	$(document).ready(
		alert($('form#submitted').val());
		function() {
		$('form#contact-us').submit(function() {
			alert('ola k ase');
			var formInput = $(this).serialize();
				$.post($(this).attr('action'),formInput, function(data){
					$('form#contact-us').slideUp("fast", function() {				   
						$(this).before('<p><strong>Gracias!</strong> Tu mensaje ha sido enviado</p>');
					});
				});
			
			
			return false;	
		});
	});

</script>
<?php $_POST['nombre']?>
 <form class="form-group" id="contact-us" method="post">
	<input type="text" class="form-control" value="<?php if(isset($_POST['nombre'])) echo $_POST['nombre'];?>" placeholder="Ingrese su nombre" name="nombre" required>
	<input type="email" class="form-control" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" placeholder="Ingrese su correo electrónico" name="email" required>
    <textarea class="form-control" value="<?php if(isset($_POST['body'])) echo $_POST['body'];?>" placeholder="Ingrese su consulta o comentario" name="body" required></textarea>
    <input type="submit" id="btnSubmit" class="btn btn-lg btn-success" onsubmit="javascript:alert('ola k ase');" value="Enviar">
	<input type="hidden" name="submitted" id="submitted" value="true" />
</form>